//@ts-nocheck
import React from '../../react'
import ReactDOM from '../../react-dom';

function FunctionCounter(props){
  return (
    <div id={'counter' + props.number}>
      <p>{props.number}</p>
      <button onClick={props.handleClick}>+</button>
    </div>
  )
}

/** 测试vdom.tsx updateFunctionComponent */
class Counter extends React.Component {
  constructor(props) {
    super(props);
    this.state = {number: 0}
  }

  handleClick = () => {
    this.setState(state => ({number: state.number + 1}));
  };

  render(){
    return (
      <FunctionCounter number={this.state.number} handleClick={this.handleClick}/>
    );
  }
}

ReactDOM.render(
  <Counter/>,
  document.getElementById('root')
);
